import { IsNotEmpty, IsString, MinLength, IsEmail, IsOptional, IsEnum } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { UserRole } from '../../common/enums';

export class CreateUserDto {
  @ApiProperty({
    description: '用户唯一用户名',
    example: 'zhangsan',
  })
  @IsNotEmpty()
  @IsString()
  username: string;

  @ApiProperty({
    description: '用户密码，需符合安全策略',
    example: 'P@ssw0rd!',
    minLength: 8,
  })
  @IsNotEmpty()
  @IsString()
  @MinLength(8, { message: 'Password must be at least 8 characters long' })
  password: string;

  @ApiProperty({
    description: '手机号（非唯一，仅作为联系方式）',
    example: '13812345678',
    required: false,
  })
  @IsOptional()
  @IsString()
  phone?: string;

  @ApiProperty({
    description: '用户角色，默认 user',
    enum: UserRole,
    default: UserRole.USER,
  })
  @IsNotEmpty()
  @IsEnum(UserRole)
  role: UserRole;

  @ApiProperty({
    description: '用户显示名称',
    example: '张三',
    required: false,
    maxLength: 64,
  })
  @IsOptional()
  @IsString()
  displayName?: string;
}
